#!/bin/sh

# Slackware build script for hatari_tos_roms
# Written by B. Watson (yalhcru@gmail.com)

# The version number is just the date when the script was written.
# The actual TOS ROM versions are 1.02-uk, 2.06-uk, and optionally
# 1.02-us and 2.06-us.

# the US ROMs are optional. They come from
# http://steem.atari.st/tos_us.zip
# (md5sum bf250988783a0d468711a1057215fd73)
# If they're present, they get included in the package, and the
# slack-desc gets modified to say so.

PRGNAM=hatari_tos_roms
VERSION=${VERSION-20090122}
ARCH=noarch
BUILD=${BUILD-1}
TAG=${TAG-_SBo}

CWD=$(pwd)
TMP=${TMP-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $PKG/usr/share/hatari $PKG/install

cd $PKG/usr/share/hatari
unzip $CWD/tos_uk.zip

mv Tos206.img tos-2.06-uk.img
mv Tos102.img tos-1.02-uk.img

US="$PRGNAM: This package includes only the UK ROM images."
if [ -f $CWD/tos_us.zip ]; then
	unzip $CWD/tos_us.zip
	mv Tos206us.img tos-2.06-us.img
	mv Tos102us.img tos-1.02-us.img
	US="$PRGNAM: This package includes both the US and UK ROM images."
fi

# hatari uses this image by default.
# 1.02 is better for games...
ln -s tos-1.02-uk.img tos.img

cat $CWD/slack-desc >$PKG/install/slack-desc
echo "$US" >> $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
